# Maintainer: Antonio Rojas <arojas@archlinux.org>

_pyname=cvxpy
pkgname=python-$_pyname
pkgver=1.4.1
pkgrel=3
pkgdesc='A Python-embedded modeling language for convex optimization problems'
url='https://www.cvxpy.org/'
license=(Apache)
arch=(loong64 x86_64)
depends=(gcc-libs
         glibc
         python
         python-clarabel
         python-ecos
         python-numpy
         python-osqp
         python-scipy
         python-scs)
makedepends=(pybind11
             python-build
             python-installer
             python-setuptools
             python-wheel)
optdepends=('python-cvxopt: GLPK solver'
            'python-cylp: CBC solver'
            'python-pyscipopt: SCIP solver')
checkdepends=(python-ecos
              python-osqp
              python-pytest
              python-scs)
source=(https://github.com/cvxpy/cvxpy/archive/v$pkgver/$pkgname-$pkgver.tar.gz)
sha256sums=('9f97db012eb9e9f6ed784b4e3d143bb388df3f9e7393d2f2bb983f7c44d3d25f')

prepare() {
  sed -e 's|,<1.24||' -i $_pyname-$pkgver/pyproject.toml # Drop version constraints
}

build() {
  cd $_pyname-$pkgver
  python -m build --wheel --no-isolation
}

check() {
  cd $_pyname-$pkgver
  python -m venv --system-site-packages test-env
  test-env/bin/python -m installer dist/*.whl
  test-env/bin/python -m pytest -v -k 'not test_scipy_mi_lp_2'
}

package() {
    cd $_pyname-$pkgver
    python -m installer --destdir="$pkgdir" dist/*.whl
}
